import winston from "winston";

const log = winston.createLogger({
  level: "info",
  format: winston.format.json(),
  defaultMeta: { service: "paimon" },
  transports: [new winston.transports.File({ filename: "log/paimon.log" })],
});

// TODO: log rotation
if (process.env.NODE_ENV !== "production") {
  log.add(
    new winston.transports.Console({ format: winston.format.combine(winston.format.splat(), winston.format.simple()) }),
  );
}

export default log;
